package cn.lizheng.web;

import cn.lizheng.dao.AdmininfoDAO;
import cn.lizheng.dao.AdmininfoDAOImpl;
import cn.lizheng.pojo.Admininfo;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet("/adminsave")
public class Adminsave extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        String adminid=req.getParameter("adminid");
        String username=req.getParameter("username");
        String password=req.getParameter("password");
        String picurl=req.getParameter("picurl");
        Admininfo p=new Admininfo();
        p.setAdminid(Integer.parseInt(adminid));
        p.setUsername(username);
        p.setPassword(password);
        p.setPicurl(picurl);
        AdmininfoDAO dao=new AdmininfoDAOImpl();
        dao.save(p);
        //页面跳转
        req.getRequestDispatcher("adminList").forward(req,resp);
    }
}
